// 项目的入口文件
import Vue from 'vue'

import 'normalize.css/normalize.css' // 样式的重置文件

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // elementui组件库的英文包

import '@/styles/index.scss' // 全局样式文件

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // 路由导航守卫(单独的抽离)

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI)

Vue.config.productionTip = false

/* Vue.directive('permission', {
  inserted(el, binding) {
    console.log(el, binding.value)
    // console.log(store.state.user.userInfo?.roles?.points)
    if (!store.getters.points.includes(binding.value)) {
      // el.remove() // 不显示这个按钮
      el.disabled = true // 直接将这个按钮禁止点击
    }
  }
}) */
// vue内置一些指令 允许自定义扩展指令
// Vue.directive('指令名', { inserted(el, binding) {} })
// Vue.directive('color', { inserted(el, binding) {
//   console.log(el) // 使用指令的dom元素
//   console.log(binding)
//   el.style.color = binding.value
// } })
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
